import { defineStore } from 'pinia'
import { removeToken, removeUser, setToken } from "@/utils/auth"

export const useUser = defineStore('user', {
    state: () => {
        return {
            userInfo: {},
            token: ""
        }
    },
    actions: {
        setBaseInfo(data) {
            const { token } = data
            this.userInfo = data
            this.token = token
            setToken(token)
        },
        logout() {
            removeToken()
            removeUser()
        }
    },
    persist: true
})